package br.com.domain;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.Table;
import javax.persistence.ManyToOne;


@Entity
@Table(name="tb_perfil_menu")
public class PerfilMenu extends Domain {

	/**************************************************************************/
	/**                                ATRIBUTOS                             **/
	/**************************************************************************/
	
	private static final long serialVersionUID = -5937682449066343789L;
	
	@Id
	@GeneratedValue(strategy = GenerationType.IDENTITY)
	@Column        (name = "idPerfilMenu")
	private Integer id;
	
	@Column(name="idMenu")
	private Integer idMenu; /** ID "MENU"  INTERNO **/
	
	@Column(name="idMenuItem")
	private Integer idMenuItem; /** ID "MENU ITEM" INTERNO **/
	
	@Column(name="nomeMenuItem")
	private String nomeMenuItem; /** NOME "MENU ITEM" INTERNO **/
	
	@JoinColumn (name = "idPerfil")
	@ManyToOne  (fetch = FetchType.EAGER, cascade=CascadeType.ALL, targetEntity = Perfil.class)
	private Perfil perfil;
	
	@Column(name="incluir" , columnDefinition="boolean default false")
	private Boolean incluir;
	
	@Column(name="alterar" , columnDefinition="boolean default false")
	private Boolean alterar;
	
	@Column(name="excluir" , columnDefinition="boolean default false")
	private Boolean excluir;
	
	@Column(name="visivel" , columnDefinition="boolean default false")
	private Boolean visivel;
	
	/**************************************************************************/
	/**                              GET's E SET's                           **/
	/**************************************************************************/
	
	public Integer getId() {
		return id;
	}

	public void setId(Integer id) {
		this.id = id;
	}

	public Perfil getPerfil() {
		return perfil;
	}

	public void setPerfil(Perfil perfil) {
		this.perfil = perfil;
	}

	public Integer getIdMenuItem() {
		return idMenuItem;
	}

	public void setIdMenuItem(Integer idMenuItem) {
		this.idMenuItem = idMenuItem;
	}

	public Integer getIdMenu() {
		return idMenu;
	}

	public void setIdMenu(Integer idMenu) {
		this.idMenu = idMenu;
	}

	public String getNomeMenuItem() {
		return nomeMenuItem;
	}

	public void setNomeMenuItem(String nomeMenuItem) {
		this.nomeMenuItem = nomeMenuItem;
	}

	public Boolean getIncluir() {
		return incluir;
	}

	public void setIncluir(Boolean incluir) {
		this.incluir = incluir;
	}

	public Boolean getAlterar() {
		return alterar;
	}

	public void setAlterar(Boolean alterar) {
		this.alterar = alterar;
	}

	public Boolean getExcluir() {
		return excluir;
	}

	public void setExcluir(Boolean excluir) {
		this.excluir = excluir;
	}

	public Boolean getVisivel() {
		return visivel;
	}

	public void setVisivel(Boolean visivel) {
		this.visivel = visivel;
	}
	
	/********************************************************************/
	/**                EQUALS E HASH CODE  - RETIRAR LIST's            **/
	/********************************************************************/

	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		result = prime * result + ((alterar == null) ? 0 : alterar.hashCode());
		result = prime * result + ((excluir == null) ? 0 : excluir.hashCode());
		result = prime * result + ((id == null) ? 0 : id.hashCode());
		result = prime * result + ((idMenu == null) ? 0 : idMenu.hashCode());
		result = prime * result
				+ ((idMenuItem == null) ? 0 : idMenuItem.hashCode());
		result = prime * result + ((incluir == null) ? 0 : incluir.hashCode());
		result = prime * result
				+ ((nomeMenuItem == null) ? 0 : nomeMenuItem.hashCode());
		result = prime * result + ((perfil == null) ? 0 : perfil.hashCode());
		result = prime * result + ((visivel == null) ? 0 : visivel.hashCode());
		return result;
	}

	@Override
	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (obj == null)
			return false;
		if (getClass() != obj.getClass())
			return false;
		PerfilMenu other = (PerfilMenu) obj;
		if (alterar == null) {
			if (other.alterar != null)
				return false;
		} else if (!alterar.equals(other.alterar))
			return false;
		if (excluir == null) {
			if (other.excluir != null)
				return false;
		} else if (!excluir.equals(other.excluir))
			return false;
		if (id == null) {
			if (other.id != null)
				return false;
		} else if (!id.equals(other.id))
			return false;
		if (idMenu == null) {
			if (other.idMenu != null)
				return false;
		} else if (!idMenu.equals(other.idMenu))
			return false;
		if (idMenuItem == null) {
			if (other.idMenuItem != null)
				return false;
		} else if (!idMenuItem.equals(other.idMenuItem))
			return false;
		if (incluir == null) {
			if (other.incluir != null)
				return false;
		} else if (!incluir.equals(other.incluir))
			return false;
		if (nomeMenuItem == null) {
			if (other.nomeMenuItem != null)
				return false;
		} else if (!nomeMenuItem.equals(other.nomeMenuItem))
			return false;
		if (perfil == null) {
			if (other.perfil != null)
				return false;
		} else if (!perfil.equals(other.perfil))
			return false;
		if (visivel == null) {
			if (other.visivel != null)
				return false;
		} else if (!visivel.equals(other.visivel))
			return false;
		return true;
	}
	
	
	
}
